home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
428_02
/
examples
/
listbox.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-13
|
780b
|
43 lines
/*
** LISTBOX.C: Lets the user select from a list of items.
*/
#include <stdio.h>
#include <pictor.h>
#define NUM_ITEMS 7
char *items[NUM_ITEMS] = {
"Apples",
"Bananas",
"Carrots",
"Grapes",
"Kiwi",
"Raisins",
"Watermelon",
};
COLORSTRUCT colors = {
foreback(BOLD+CYAN,BLUE),
foreback(BOLD+WHITE,CYAN),
foreback(BLACK,WHITE),
foreback(BOLD+WHITE,WHITE)
};
void main()
{
char buffer[45];
int sel = 0;
/* initialize the library */
initvideo();
if(listbox(items,NUM_ITEMS,&sel,"Fruit",&colors)) {
sprintf(buffer,"You selected %s",items[sel]);
messagebox(buffer,NULL,MB_OK,&colors);
}
else {
messagebox("You pressed <Escape>",NULL,MB_OK,
&colors);
}
}